import { exec } from "child_process";
import express from "express";
const router = express.Router();
const pwd = "/usr/local/shuwan9/";
router.get("/pull", (req, res) => {
  const { repo } = req.query;
  if (!repo) {
    return res.json({
      code: -1,
      msg: "请输入repo",
    });
  }
  exec(`cd ${pwd}${repo} && git pull`, (err, stdout) => {
    if (err) {
      return res.json({
        code: 1,
        msg: err,
      });
    }
    return res.json({
      code: 0,
      msg: stdout,
    });
  });
});
export { router };
